package com.dycx.user.enums;

import lombok.Getter;

import java.util.*;

/**
 * @author 售票类型
 * @date 2023/2/23
 */
@Getter
public enum SeatStatusEnum {
    SEAT_STATUS_CAN_SALE(1, "可售", "success"),
    SEAT_STATUS_DID_SALE(2, "已售", "danger"),
    SEAT_STATUS_LOCK(3, "占座", "warning"),
    SEAT_STATUS_STOP(4, "停用", "info");

    private final Integer code;
    private final String name;
    private final String style;

    SeatStatusEnum(Integer code, String name, String style) {
        this.code = code;
        this.name = name;
        this.style = style;
    }

    public static SeatStatusEnum converter(Integer code) {
        return Arrays.stream(values()).filter(en -> en.code.equals(code)).findAny().orElse(SEAT_STATUS_CAN_SALE);
    }

    /**
     * 转为数据
     *
     * @return 枚举对象数组
     */
    public static List<Map<String, Object>> getList() {
        List<Map<String, Object>> list = new ArrayList<>();
        for (SeatStatusEnum item : SeatStatusEnum.values()) {
            Map<String, Object> map = new HashMap<>();
            map.put("code", item.getCode().toString());
            map.put("name", item.getName());
            list.add(map);
        }
        return list;
    }
}
